package com.briup.day05;

import java.util.Scanner;

/**
 * @author ThinkBook
 */
public class Test01_Bits {
    //方法的定义
    public static int setOne(int m, int n) {
        return m | (1 << (n - 1));
    }

    //方法调用测试
    public static void main(String[] args) {
        int r = setOne(10,5);
        System.out.println("将10的第5位置为1：" + r);

        r = setOne(8,3);
        System.out.println("将8的第3位置为1：" + r);
    }
    public static void main01(String[] args) {
//        位运算符测试
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int n = scanner.nextInt();
//        操作符存在优先级  +的优先级高于&
        System.out.println(m + "&"+ n +":"+ (m & n));
        System.out.println(m + "|"+ n +":"+ (m | n));
        System.out.println(m + "^"+ n +":"+ (m ^ n));

//        置1操作
        int r = m | (1 << (n - 1)) ;
        System.out.println("置1 结果: " + r);
//        置0操作
        r = ~(1 << (n - 1)) & m;
        System.out.println("置0 结果: " + r);
    }
}
